/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.core.multithreading;

import java.lang.Thread;
import java.applet.Applet;

public class MultiThread extends Applet implements Runnable {

    Thread myThread;

    public void init() {
        System.out.println("in init() -- starting thread.");
        myThread = new Thread(this);
        myThread.start();
    }

    public void start() {
        System.out.println("in start() -- resuming thread.");
        myThread.resume();
    }

    public void stop() {
        System.out.println("in stop() -- suspending thread.");
        myThread.suspend();
    }

    public void destroy() {
        System.out.println("in destroy() -- stoping thread.");
        myThread.resume();
        myThread.stop();
    }

    public void run() {
        int i = 0;
        for (;;) {
            i++;
            System.out.println("At " + i + " and counting!");
            try {
                myThread.sleep(1000);
            } catch (InterruptedException e) {
            }
        }
    }
}
